package com.solome.logic;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.SplitPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.solome.base.AbstractScreen;
import com.solome.ui.SoLableTTF;
import com.solome.ui.SoScrollView;
import com.solome.ui.SoScrollView.SoScrollType;
import com.solome.util.FontFactory;

/**
 * 登录
 * 
 * @author Administrator
 *
 */
public class LoginBase extends AbstractScreen {
	final Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

	public LoginBase(Game game) {
		super(game);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init() {
		Texture texture = new Texture("Resources/image/1.jpg");
		Image image = new Image(texture);
		System.out.println("=========" + image.getWidth() + ","
				+ image.getHeight());
		System.out.println(image.getWidth());
		System.out.println(image.getHeight());
		// this.addChild(image, 0);
		Table table = new Table();
		SoScrollView scrollView = SoScrollView.create(SoScrollType.Horizontal);
		scrollView.setFadeScrollBars(true);
		scrollView.setFlickScroll(true);
		scrollView.setBounds(0, 0, image.getWidth(), image.getHeight());
		scrollView.setScrollingDisabled(false, false);
		scrollView.setFlickScrollTapSquareSize(20);
		table.add(image);
		texture = new Texture("Resources/image/2.jpg");
		image = new Image(texture);
		table.add(image);
		texture = new Texture("Resources/image/3.jpg");
		image = new Image(texture);

		table.add(image);
		scrollView.addChild(table);

		Object[] listEntries = { "This is a list entry1", "And another one1",
				"The meaning of life1", "Is hard to come by1",
				"This is a list entry2", "And another one2",
				"The meaning of life2", "Is hard to come by2",
				"This is a list entry3", "And another one3",
				"The meaning of life3", "Is hard to come by3",
				"This is a list entry4", "And another one4",
				"The meaning of life4", "Is hard to come by4",
				"This is a list entry5", "And another one5",
				"The meaning of life5", "Is hard to come by5" };
		ScrollPane scrollPane = new ScrollPane(image);
		List list = new List(skin);
		list.setItems(listEntries);
		list.getSelection().setMultiple(true);
		list.getSelection().setRequired(false);
		// list.getSelection().setToggle(true);
		ScrollPane scrollPane2 = new ScrollPane(list, skin);
		scrollPane2.setFlickScroll(false);
		SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false,
				skin, "default-horizontal");
		// Table table = new Table();
		// table.add(image);
		// table.add(image);
		// table.add(image);
		this.add(splitPane);
		// // TODO Auto-generated method stub
		// Texture texture = new Texture("image/bgchapter.jpg");
		// Image image = new Image(texture);
		// System.out.println(image.getWidth());
		// System.out.println(image.getHeight());
		// this.addChild(image, 0);
		SoLableTTF lableTTF = new SoLableTTF("欢迎来到游戏来到游戏来到游戏来到游戏世界", 20,
				Color.BLUE);
		lableTTF.setPosition(new Vector2(240, 0));
		// lableTTF.setAnchorPoint(new Vector2(0.5f, 0));
		this.add(lableTTF, 0);
		//
		lableTTF = new SoLableTTF(
				"This is a test\nAnd another line\n()����$%&/!12390#", 25,
				Color.BLUE);
		lableTTF.setPosition(new Vector2(240, 22));
		this.add(lableTTF, 0);
		//
		lableTTF = new SoLableTTF("欢迎来到游戏来到游戏来到游戏来到游戏世界", 30, Color.RED);
		lableTTF.setPosition(new Vector2(240 / 2, 44));
		this.add(lableTTF, 0);
		Label label = new Label("你好 ", new LabelStyle(FontFactory.getInstance()
				.init("", 30), Color.BLUE));
		label.setPosition(100, 100);
		this.add(label, 0);
		//
		// SoScrollView scrollView = SoScrollView.create(SoScrollType.Vertical);
		// scrollView.addChild(new Label("菜单 ", new LabelStyle(
		// FontFactory.getInstance().init("", 30), Color.RED)));
		// scrollView.addChild(new Label("代码 ", new LabelStyle(
		// FontFactory.getInstance().init("", 30), Color.RED)));
		// scrollView.addChild(new Label("礼拜", new LabelStyle(
		// FontFactory.getInstance().init("", 30), Color.RED)));
		// scrollView.setBounds(50, 100,200,50);
		// this.addChild(scrollView, 0);

		Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
		BitmapFont font = FontFactory.getInstance().init("", 12);
		LabelStyle style = new LabelStyle();// skin.get(LabelStyle.class);
		style.font = font;
		label = new Label("原生label.....放大3倍", style);
		label.setPosition(10, 500);
		this.add(label, 1);

		label = new Label(
				"<<[BLUE]M[RED]u[YELLOW]l[GREEN]t[OLIVE]ic[]o[]l[]o[]r[]*[MAROON]Label[][] [Unknown Color]>>",
				skin);
		label.setPosition(100, 200);
		this.add(label);

		// 读取skin 或者自定义TextFieldStyle
		// TextFieldStyle fieldStyle = skin.get(TextFieldStyle.class);
		// // // 移除skin中的BitmapFont
		// fieldStyle.font.dispose();
		// // // 替换skin中的BitmapFont
		//
		// TextFieldStyle fieldStyle = new TextFieldStyle();
		// fieldStyle.font = FontFactory.getInstance().getFont(30);
		// TextField textfield = new TextField("", fieldStyle);
		// textfield.setWidth(500);
		// textfield.setMessageText("请点击这里!");
		// textfield.setAlignment(Align.center);
		// textfield.setPosition(250, 550);
		// this.addChild(textfield, 1);
		//
		// TextArea textArea = new TextArea("", fieldStyle);
		// textArea.setMessageText("请输入文本信息.");
		// textArea.setBounds(10, 400, 300, 300);
		// this.addChild(textArea, 1);

		setInputAdapter();
	}

	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		System.out.println("touch=" + screenX + "," + screenY);
		return super.touchDown(screenX, screenY, pointer, button);
	}

	@Override
	public void draw(float delta) {
		// TODO Auto-generated method stub

	}

	@Override
	public void free() {
		// TODO Auto-generated method stub

	}

}
